# find libxml-2.0
# Once done this will define
# libxml2_FOUND
# libxml2_INCLUDE_DIRS - The libxml-2.0 include directories
# libxml2_LIBRARIES    - The libraries needed to use libxml-2.0
# libxml2_DEFINITIONS  - Compiler switches required for using libxml-2.0

find_package(PkgConfig)
pkg_check_modules(PC QUIET libxml-2.0)

#message(STATUS "LIBRARIES    : ${PC_LIBRARIES}")
#message(STATUS "LIBRARY DIRS : ${PC_LIBBRARY_DIRS}")
#message(STATUS "LDFLAGS      : ${PC_LDFLAGS}")
#message(STATUS "LDFLAGS OTHER: ${PC_LDFLAGS_OTHERS}")
#message(STATUS "INCLUDE DIRS : ${PC_INCLUDE_DIRS}")
#message(STATUS "CFLAGS       : ${PC_CFLAGS}")
#message(STATUS "CFLAGS OTHER : ${PC_CFLAGS_OTHER}")

set(libxml2_DEFINITIONS ${PC_CFLAGS_OTHER})

find_path(libxml2_INCLUDE_DIR libxml/xmlmemory.h
        HINTS ${PC_INCLUDE_DIRS}
	PATH_SUFFIXES libxml2)

find_library(libxml2_LIBRARY NAMES xml2
        HINTS ${PC_LIBRARY_DIRS} )

set(libxml2_LIBRARIES ${libxml2_LIBRARY} )
set(libxml2_INCLUDE_DIRS ${libxml2_INCLUDE_DIR} )

include(FindPackageHandleStandardArgs)
# handle the QUIETLY and REQUIRED arguments and set libxml2_FOUND to TRUE
# if all listed variables are TRUE
find_package_handle_standard_args(libxml2 DEFAULT_MSG
	libxml2_LIBRARY libxml2_INCLUDE_DIR)

mark_as_advanced(libxml2_INCLUDE_DIR libxml2_LIBRARY )
